package com.xueyi.starter.file.config;

import io.minio.MinioClient;
import lombok.Getter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 描述 MINIO自动配置Config
 *
 * @author 俞烨
 * @date 2024-03-09 21
 */
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(FileMinioSystemAutoProperties.class)
@Getter
public class MinioAutoConfiguration {


    @Resource
    private FileMinioSystemAutoProperties fileMinioSystemAutoProperties;


    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(fileMinioSystemAutoProperties.getUrl())
                .credentials(fileMinioSystemAutoProperties.getAccount(),
                        fileMinioSystemAutoProperties.getPassword())
                .build();
    }
}
